package com.itheima.controller.backend.security.admin;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.Result;
import com.itheima.common.pojo.Order;
import com.itheima.common.pojo.OrderSetting;
import com.itheima.common.pojo.dto.OrderSettingPageQueryDTO;
import com.itheima.service.OrderService;
import com.itheima.service.OrderSettingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderSettingService orderSettingService;


    /**
     * 分页查询预约列表
     * @param orderSettingDTO
     * @return
     */
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody OrderSettingPageQueryDTO orderSettingDTO){
        log.info("分页查询预约列表:{}",orderSettingDTO);
        PageResult pageResult = orderSettingService.pageQuery(orderSettingDTO);
        return pageResult;
    }

    /**
     * 修改预约设置
     * @param order
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody Order order){
        log.info("修改预约设置:{}",order);
        orderSettingService.update(order);
        return new Result(true,MessageConstant.ORDERSETTING_SUCCESS);
    }


}
